using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CodeStory.WebControls
{

	//[ToolboxData("<{0}:DataBoundColumn runat=server></{0}:DataBoundColumn>")]
	public class DataBoundColumn : TreeGridColumn
	{
		public string DataField {
			get { 
				object obj = ViewState["DataField"];
				return obj == null ? string.Empty : (string)obj;
			}
			set { ViewState["DataField"] = value;}
		}

		public override void BuildIn(TableCell cell, bool databound, IDataItemContainer dataItemContainer) {
			//base.BuildIn(control, item);
			if (dataItemContainer == null || dataItemContainer.DataItem == null) return;
			string text = DataBinder.GetPropertyValue(dataItemContainer.DataItem, DataField).ToString();
			cell.Text = text;
		}
	}
}
